﻿// AddDrawDlg.cpp: 实现文件
//

#include "pch.h"
#include "TestDraw.h"
#include "AddDrawDlg.h"
#include "afxdialogex.h"


// AddDrawDlg 对话框

IMPLEMENT_DYNAMIC(AddDrawDlg, CDialog)

AddDrawDlg::AddDrawDlg(CWnd* pParent /*=nullptr*/)
	: CDialog(IDD_DIALOG1, pParent)
	, m_DrawType(-1)
	, m_CenterX(0)
	, m_CenterY(0)
	, m_OffsetDistance(0)
{

}

AddDrawDlg::~AddDrawDlg()
{
}

void AddDrawDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Radio(pDX, IDC_RADIO1, m_DrawType);
	DDX_Text(pDX, IDC_EDIT_CENTER_X, m_CenterX);
	DDX_Text(pDX, IDC_EDIT_CENTER_Y, m_CenterY);
	DDX_Text(pDX, IDC_EDIT_DISTANCE, m_OffsetDistance);
}


BEGIN_MESSAGE_MAP(AddDrawDlg, CDialog)
END_MESSAGE_MAP()


// AddDrawDlg 消息处理程序

bool isDigit(const CString& str) {
	char c;
	for (int i = 0; i < str.GetLength(); i++)

	{
		c = str.GetAt(i);
		if (c >= '0 ' && c <= '9 ' || c == '.') {
			//符合数字的条件
			return true;
		}
		else {
			MessageBox(NULL, "该输入不是数字", "温馨提示 ", MB_OK);
			return false;
		}
	}
}

void AddDrawDlg::OnOK()
{
	// TODO: 在此添加专用代码和/或调用基类
	UpdateData();
	if (-1 == m_DrawType) {
		MessageBox("请选择绘图的类型");
		return;
	}
	CDialog::OnOK();
}


BOOL AddDrawDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  在此添加额外的初始化
	GetDlgItem(IDC_EDIT_CENTER_X)->SetWindowText("");
	GetDlgItem(IDC_EDIT_CENTER_Y)->SetWindowText("");
	GetDlgItem(IDC_EDIT_OFFSET_X)->SetWindowText("");

	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}
